<template>
  <div class="home">
    <el-container>
      <el-header height="48px">
        <my-header></my-header>
      </el-header>
      <el-container>
        <el-aside v-if="getAsideType!==0" :width="getAsideType===1?'200px':'48px'">
          <com-aside :datas="datas"></com-aside>
        </el-aside>
        <el-container>
          <el-main style="height: calc(100% - 78px);">
            <router-view/>
          </el-main>
          <el-footer height="30px">
            footer
          </el-footer>
        </el-container>
      </el-container>
    </el-container>
    
  </div>
</template>

<script>
import ComAside from '@/components/ComAside'
import myHeader from '@/components/header'
export default {
  name: 'Home',
  components: {
    comAside: ComAside,
    myHeader
  },
  data() {
    return {
      datas: []
    }
  },
  watch: {
    // 监听路由
    '$route': {
      immediate:true, // 立即的，会先于create开启监听，在组件加载时就调用一次
      deep:true, // 开启深遍历，监听内部变化
      handler () {
        //  获取输入框内容，定位展开位置 
        this.$store.commit('setInputValue', this.$route.query.inputValue)
      }
    }
  },
  computed: {
    getAsideType() {
      return this.$store.state.asideType
    }
  },
  async mounted () {
    // 获取datas
    let datas = () => {
      return import('@/utils/datas.json')
    }
    this.datas = JSON.parse(JSON.stringify(await datas())).default
  },
  methods: {
  }
}
</script>

<style lang="less" scoped>
.home ::v-deep {
  height:100%;
  .el-container {
    width: 100%;
    height:100%;
  }
  .el-header {
    background: blue;
    line-height: 48px;
    padding: 0;
  }
  .el-footer {
    border-top: 1px solid #ccc;
    line-height:30px;
    font-size: 12px;
    color: #ccc;
    text-align: center;
  }
}
</style>
